<template>
  <view class="enlargeView" v-if="showImage" @click="hiddenEnlargeFunc">
    <image
      :src="'data:image/png;base64,' + imgSrc"
      :class="['enlarge-img ', type == 1 ? 'tiaoxingma' : '']"
    />
  </view>
</template>

<script>
export default {
  data() {
    return {
      showImage: false,
      //1 :条形码  2：二维码
      type: null,
      list: [],
      dialogVisible: false,
      resolve: null,
      reject: null,
      originScreenBrightness: null,
      imgSrc: "",
    };
  },
  watch: {},
  methods: {
    dialogShow(img, type) {
      wx.getScreenBrightness({
        success: (res) => {
          if (res.value < 0.75) {
            wx.setScreenBrightness({ value: 0.75 });
          }
          this.originScreenBrightness = res.value;
        },
      });
      (this.imgSrc = img), (this.type = type);

      this.showImage = true;

      wx.setScreenBrightness({
        value: 0.7,
      });
      wx.setKeepScreenOn({
        keepScreenOn: false,
      });
    },
    hiddenEnlargeFunc() {
      this.showImage = false;
      wx.setScreenBrightness({ value: this.data.originScreenBrightness });
    },

    handleStop() {
      return false;
    },
  },
};
</script>

<style lang="scss" scoped>
.enlargeView {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background-color: #fff;
  .enlarge-img {
    width: 500rpx;
    height: 500rpx;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .tiaoxingma {
    width: 650rpx;
    height: 150rpx;
  }
}
</style>